<?php 
picture_category::$_lang = $this->user->getLang();
if(!function_exists('_categoryTree')) {
	function _categoryTree($tree) {
		$obj = system_view::getControllerActionViewInstance();
		$str = "";
		foreach((array) $tree AS $row) {
			$url = (string) $obj->url('picture/category/edit', array('id' => $row['id']));
			$url1 = (string) $obj->url('picture/category/special', array('id' => $row['id']));
			$url2 = (string) $obj->url('picture/category/move', array('id' => $row['id']));
			$url3 = (string) $obj->url('picture/category/delete', array('id' => $row['id']));
			$str .= '<ul class="sub">';
			$str .= '<li><a href="' . $url . '">' . $row['title'] . '</a>';
			$str .= '[<em>' . $row['id'] . '</em>] - ';
			$str .= '<a href="' . $url1 . '">' . $obj->language('Special') . '(<em class="red">' . $row['stotal'] . '</em>)</a> / ';
			$str .= '<a href="' . $url . '">' . $obj->language('Edit') . '»</a> / ';
			$str .= '<a href="' . $url2 . '">' . $obj->language('Move To') . '»</a> / ';
			$str .= '<a href="' . $url3 . '">' . $obj->language('Delete') . '»</a>';
			if(!empty($row['children'])) {
				$str .= _categoryTree($row['children']);
			}
			$str .= '</li></ul>';
		}
		return $str;
	}
}
?><div class="body">
	<div class="msg">
		<div class="common helper">
			<i class="icon"></i><h4><?php echo $this->language('CATEGORY MANAGEMENT')?>:</h4>
			<div class="msg-bd">
				<ul class="guide">
					<li><a href="<?php echo $this->url('picture/category/addnew', array('parent' => 0));?>"><?php echo $this->language('CREATE A NEW CATEGORY')?> »</a></li>
					<li>
						<a href="<?php echo $this->url('picture/category/list');?>"><?php echo $this->language('List Top Category')?> »</a>						
						<?php echo _categoryTree(picture_category::allCategoryToTreeAsArray());?>
					</li>
				</ul>
				<br/>
			</div>
		</div>	
	</div>	
</div>